#include<bits/stdc++.h>
using namespace std;
int a[100005];
int b[100005];
int cnt=0;
void f(int x){
    for(int i=x;i>=1;i--){
        for(int j=1;j<=x;j++){
            if(a[i]>a[j]){
                cnt++;
                a[j]=200000;
                break;
            }
        }
    }
}
int main(){
    freopen("duel.in","r",stdin);
    freopen("duel.in","w",stdout);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[a[i]]++;
    }
    sort(a+1,a+n);
    if(b[1]!=0 && b[2]!=0 && n>10 && n<=100000){
        int cnt;
        cnt=b[1]-b[2];
        if(cnt<0) cnt = 0;
        cout<<b[2]+cnt;
    }
    f(n);
    cout<<n-cnt/2;
    return 0;
}

//65376
//36247
